/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session;

import entity.Commande;
import entity.ElementCommande;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author livetnediser
 */
@Stateless
public class ElementCommandeFacade extends AbstractFacade<ElementCommande> {
    @PersistenceContext(unitName = "SexyShopPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public ElementCommandeFacade() {
        super(ElementCommande.class);
    }
    
    public List<ElementCommande> findByIdCommand(Commande idCommand) {
        List<ElementCommande> aux = em.createQuery("SELECT e FROM ElementCommande e WHERE e.idCommande = :idCommand")
        .setParameter("idCommand", idCommand)
        .getResultList();
	if(aux != null && aux.size()>0){
	    return aux;
	} else{
	    return null;
	}
    }
    
}
